package com.duan.blog.controller;

import com.duan.blog.common.RespUtil;
import com.duan.blog.model.User;
import com.duan.blog.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;

    @RequestMapping("/getUser")
    public RespUtil selectUserById(@RequestParam("userId") Integer userId){
        User user = userService.selectUserById(userId);
        return RespUtil.success(user);
    }

    @RequestMapping("/getAllUser")
    public RespUtil selectAllUsers(){
        List<User> userList = userService.selectAllUser();
        return RespUtil.success(userList);
    }



}
